import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 * Date: 2024-03-31
 * Time: 17:38
 */

/**
 * 反射私有方法
 */
public class Demo4 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
        Class c4=null;
        c4=Class.forName("Student");
        Method method=c4.getDeclaredMethod("function",String.class);
        method.setAccessible(true);
        Object object=c4.newInstance();

        Student student =   (Student) object;
        method.invoke(student,"我好牛逼啊");

    }
}
